package com.estronger.shopmanage.ui.grab.presenter;

import android.content.Context;

import com.google.gson.Gson;
import com.soonfor.evaluate.http.api.Request;
import com.soonfor.evaluate.http.httptools.AsyncUtils;

/**
 * Created by Administrator on 2018-01-29.
 */

public class GrabComPresenter implements AsyncUtils.AsyncCallback{

    private Context mContext;
    private IGrabComView view;

    public GrabComPresenter(Context mContext, IGrabComView view){
        this.mContext = mContext;
        this.view = view;
    }
    /**
     * 抢单
     *
     * @param taskid
     */
    public void grabTask(String taskid, int tasktype) {
        Request.Grab.postToGrab(mContext, taskid, tasktype, this);
    }


    @Override
    public void success(int requestCode, String data) {
        Gson gson = new Gson();
        switch (requestCode) {
            case Request.Grab.POST_GRAB:
                view.refreshAfterGrabTask(true, null);
                break;
        }
    }

    @Override
    public void fail(int requestCode, int statusCode, String data, String msg) {
        if(requestCode == Request.Grab.POST_GRAB){
            //view.refreshAfterGrabTask(false, headBean.getFaileMsg());
            view.refreshAfterGrabTask(false, "抢单不成功:" + msg);
        }
    }
}
